#include <vector>
#include <iostream>
#include <fstream>

using namespace std;

const int INF = numeric_limits<int>::infinity();

int main() {
	ifstream input("INPUT.txt", ifstream::in);
	int quantity;
	input >> quantity;
	vector<vector<double>> Rate(quantity);

	for(int i = 0; i < quantity; ++i)
		for(int j = 0; j < quantity; ++j) {
			double itoj;
			input >> itoj;
			if (itoj != 0)
				Rate[i].push_back(-log(itoj));
			else Rate[i].push_back(- INF);
		}
	
	input.close();

	vector <double> Distance;

	Distance.push_back(0);
	for(int i=1; i<quantity; ++i)
		Distance.push_back(INF);

	vector <int> Cycle(quantity);

	for(int p = 1; p < quantity; ++p)
		for(int i = 0; i < quantity; ++i)
			for(int j = 0; j < quantity; ++j)
				if ( Distance[i] + Rate[i][j] < Distance[j] ) {
					Distance[j] =Distance[i] + Rate[i][j];
					Cycle[i] = j;
				}
	int i = 0, j = 0;
	while( i<quantity && j<quantity && Distance[i] + Rate[i][j] >= Distance[j] ) {
		j++;
		if (j == quantity) {
			i++;
			j=0;
		}
	}
	if (i != quantity) {
		int tmp = i;
		do {
			cout << tmp+1 << ' ';
			tmp = Cycle[tmp];
		} while (tmp != i);
		cout << i + 1 << endl;
	}
	else 
		cout << "No" << endl;
	
	system("pause");
	return 0;
}